//
//  TimeBarView.h
//  FruitCrush
//
//  Created by gaoyu on 15/7/19.
//
//

#ifndef __FruitCrush__TimeBarView__
#define __FruitCrush__TimeBarView__

#include "cocos2d.h"
USING_NS_CC;

typedef std::function<void(Ref*)> timeBarViewCallback;

#define TIME_BAR_VIEW_WIDTH    110
#define TIME_BAR_VIEW_HEIGHT   30
#define TIME_BAR_YPAD          20

class TimeBarView : public cocos2d::Layer
{
public:
    static TimeBarView *create(int max);
    bool init(int max);
    TimeBarView();
    virtual void update(float dt) override;
    void setCallback(const timeBarViewCallback& callback);
    void setPause(bool pause);
    void changeTime(float time);
    void recordTime();
protected:
    // callback
    timeBarViewCallback _callback;
    
private:
    Sprite *star1;
    Sprite *star2;
    Sprite *star3;
    bool m_isPause;
    void bgInit();
    void progressBarInit();
    ProgressTimer *timeBar;
    CC_SYNTHESIZE(float, lastTime, LastTime);
    CC_SYNTHESIZE(float, maxTime, MaxTime);
    void starInit();
    void showAction();
    
};


#endif /* defined(__FruitCrush__TimeBarView__) */
